package com.wd.live.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.wd.live.base.BaseViewModel;
import com.wd.live.bean.SignBean;
import com.wd.live.model.HttpUtils;
import com.wd.live.model.SpUtils;


import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class SiginModel extends BaseViewModel {
    public SiginModel(@NonNull Application application) {
        super(application);
    }
    MutableLiveData<SignBean> SignData=new MutableLiveData<>();

    public MutableLiveData<SignBean> getSignData() {
        String userId = SpUtils.getString("uid", "");
        Integer integer = Integer.valueOf(userId);
        String sessionId = SpUtils.getString("sid", "");
        HttpUtils.getHttpUtils().getApi().findLabels(integer,sessionId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<SignBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(SignBean value) {
                    SignData.postValue(value);
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
        return SignData;
    }
}
